package teamproject.visualization.calculations;

public class PackageMarker {

	private boolean[] marked;
	private int numberOfPacketsPerInterval;
	private int numberOfPacketsToBeDisplayed;

	public PackageMarker(int numberOfPacketsPerInterval,
			int numberOfPacketsToBeDisplayed) {
		this.numberOfPacketsPerInterval = numberOfPacketsPerInterval;
		this.numberOfPacketsToBeDisplayed = numberOfPacketsToBeDisplayed;
		marked = new boolean[this.numberOfPacketsPerInterval];
	}

	/**
	 * Calculates which packet is to be displayed in the interval. The indices
	 * of the returned area that are true indicate which packet is to be
	 * displayed.
	 * 
	 * @return boolean[] whose indices are true for which the respective packet
	 *         will be displayed.
	 */
	public boolean[] getPacketsToBeDisplayed() {
		if (numberOfPacketsToBeDisplayed != 0) {
			int index = numberOfPacketsPerInterval
					/ numberOfPacketsToBeDisplayed;

			for (int i = 0; i < marked.length; i++) {
				if (i % index == 0)
					marked[i] = true;
				else
					marked[i] = false;
			}
		} else {
			for (int i = 0; i < marked.length; i++) {
				marked[i] = false;
			}
		}

		return marked;
	}
}
